//
// Created by Administrator on 2021/10/21.
//

#include "Camera.h"

Camera::Camera() {
    type = GET_CLASS(__FILE__);
    name = type + "_" + id;
}

Camera::~Camera() {
    log_info("gc Camera! %p", this);
}

void Camera::drawUI() {
    Object3D::drawUI();

    bool refreshAttri = false;

    if(ImGui::DragFloat("left", &left, 0.1f, -1000.0f, 0.0f)){
        refreshAttri = true;
    }

    if(ImGui::DragFloat("right", &right, 0.1f, 0.0f, 1000.0f)){
        refreshAttri = true;
    }

    if(ImGui::DragFloat("bottom", &bottom, 0.1f,  -1000.0f, 0.0f)){
        refreshAttri = true;
    }

    if(ImGui::DragFloat("top", &top, 0.1f,  0.0f, 1000.0f)){
        refreshAttri = true;
    }

    if(ImGui::DragFloat("near", &nearplan, 0.1f, 0.0f, 50.0f)){
        refreshAttri = true;
    }
    if(ImGui::DragFloat("far", &farplan, 0.1f, 0.0f, 2000.0f)){
        refreshAttri = true;
    }
    ImGui::Checkbox("Preview", &bPreview);

    if(refreshAttri){ // todo 等待优化
        onInit();
    }
}

void Camera::onInit() {

    Object3D::onInit();
}



